SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00004 1 05-25-9408:13ALL JUSTIN FERGUSON FergSoft! ReadLn SWAG9405 61 3 {π Ok, y'all, here's a function I've been working on for a while, andπ I thought I'd post it for everybody. It's a modified ReadLnπ routine, and while there's no guarantees, <What's new?>, I _think_π it's bug free. <Crossing fingers> If y'all want to use it, goπ ahead, but I would like some credit, 'cuz it took me a while. Justπ credit FergSoft!, Artificial Reality, Whizard, or Justin Ferguson.π It's fairly well commented, but just throw any questions you mayπ have my way...ππ--- Cut Here ---π}ππunit FSRead;ππ{------------------------------------------------------------------------}π{π FergSoft! ReadLn Routine:ππ By Justin Ferguson of FergSoft!,π a. k. a. Whizard of Artificial Reality.ππ FSReadLn reads a string of specified length, at specifiedπ location, in specified colors, terminated by TAB or Enter.ππ Feel free to use this little unit anywhere y'all want, just giveπ credit for it.πππ Thanx, Whizardππ }π{------------------------------------------------------------------------}ππINTERFACEππuses Crt;ππFunction FSReadLn (X, {X Location}π Y, {Y Location}π FC, {Foreground Color}π BC, {Background Color}π StrLength : Byte; {Length of string to input. Will beπ padded with spaces (#32). }ππ Default : String {Default string, leave '' for noπ default }π ) : String;ππ{------------------------------------------------------------------------}ππIMPLEMENTATIONππFunction FSReadLn (X, Y, FC, BC, StrLength : Byte; Default : String)π : String;ππvar Temp : String; {Temporary string}π Location : Byte; {Current location in string}π QuitFlag, InsFlag : Boolean; {Flags}π Ch : Char; {Current Character}π Z : Integer; {Temp variable}π Cursor : Word absolute $0040:$0060; {Cursor format}ππbeginπ QuitFlag := False;π InsFlag := True;ππ For Z := 1 to 255 do {Clear string to spaces}π Temp[Z] := ' ';ππ For Z := 1 to Length(Default) do {Set to default string}π Temp[Z] := Default[Z];ππ Temp[0] := Chr(StrLength); {Set length of string}π Location := 1;π Ch := #1;π Temp[StrLength + 1] := #32;π GotoXY(X, Y);π Write(Temp);ππ Repeatπ Case Ch ofπ #32..#127 : begin {Regular ASCII}π If InsFlag = False thenπ beginπ If Location <= StrLength thenπ beginπ Location := Location + 1;π Temp[Location] := Ch;π end;π endπ elseπ beginπ If Location <= StrLength thenπ beginπ For Z := StrLength - 1 downtoπ Location doπ Temp[Z + 1] := Temp[Z];ππ Temp[Location] := Ch;π Location := Location + 1;π end;π end;π end;π #27 : begin {ESC}π For Z := 1 to StrLength doπ Temp[Z] := ' ';π Location := 1;π end;π #9, #13 : QuitFlag := True; {Tab}{Enter}π #8 : begin {Backspace}π If Location > 1 thenπ beginπ Location := Location - 1;π For Z := Location to StrLength doπ beginπ Temp[Z] := Temp[Z + 1];π end;π end;π end;ππ #0 : begin {Extended keys... }π Ch := ReadKey;π Case Ch ofππ #75 : begin {Left arrow}π If Location > 1 thenπ Location := Location - 1;π end;π #77 : begin {Right arrow}π If Location < (StrLength - 1) thenπ Location := Location + 1;π end;π #71 : Location := 1; {Home}π #79 : Location := StrLength; {End}π #82 : If InsFlag = True {Insert}π thenπ beginπ InsFlag := False;π asmπ MOV AH, $01π MOV CX, $0Fπ INT $10π end;π endπ elseπ beginπ InsFlag := True;π asmπ MOV AH, $01π MOV CL, $07π MOV CH, $06π INT $10π end;π end;π {Delete}π #83 : For Z := Location to StrLength doπ Temp[Z] := Temp[Z + 1];π end;π end;π end;ππ Temp[StrLength + 1] := #32;π GotoXY(X, Y);π Write(Temp);ππ TextColor(12);π GotoXY(79, 25);π If InsFlag = True then Write('I') else Write(' ');π {Note: Take out above 3 lines to not put an insertπ status 'I' at the bottom of the screen }ππ TextColor(FC);π TextBackground(BC);π GotoXY(X + Location - 1, Y);π If QuitFlag <> True then Ch := ReadKey;ππ until QuitFlag = True;ππ Temp[0] := Chr(StrLength);πend;ππ{--------------------------------------------------------------------------}ππbeginπend.π 2 05-25-9408:20ALL RICHARD FURMAN Readline Function SWAG9405 17 3 {πThe Readln statement can't really be used here, because this interchange isπtaking place in Graphics mode. I am writing a Graphics application thatπdoes take user inputπ}πFunction KBString:String; {* Gets string from keyboard using Scankey *}π Varπ bu,X,Inchar:Integer;π STRBUFF:STRING;π beginπ STRBUFF := '';π X:=20;π Repeatπ Inchar := Scankey;π IF FK and (Inchar = 60) thenπ Beginπ Cancel := True;π Exit;π End;π setcolor(0);π setlinestyle (0,0,1);π Rectangle(15,70,X+5,90);π setcolor(BLDCLR);π If Not FK then outtextxy (x,77,CHR(INCHAR));π If inchar <> 8 thenπ Beginπ X := X+ Textwidth(CHR(INCHAR));π setcolor(txtclr);π Rectangle(15,70,X+5,90);π Endπ elseπ beginπ setcolor(0);π setlinestyle (0,0,1);π Rectangle(15,70,X+5,90);π x:=x-textwidth(Strbuff[length(strbuff)]);π outtextxy(X,77,strbuff[length(strbuff)]);π setcolor(txtclr);π Rectangle(15,70,x+5,90);π Delete(Strbuff,Length(Strbuff),1);π setcolor(BLDCLR);π End;π If (Not FK) and (Inchar <> 8) then STRBUFF := STRBUFF +π CHR(Inchar);π Until inchar = 13;π Delete(strBuff,Length(StrBuff),1);π setcolor(txtclr);π KBString := STRBUFF;π End;ππThis code snippet should give you some ideas on getting user input. BTWπSCANKEY is a function I wrote to read the keyboard. You should be able toπuse READKEY in its place. This routine also features the ability to editπwith the backspace key. I hope it helps.π 3 05-26-9410:58ALL RICHARD GRIFFIN Simple Entry Routine SWAG9405 84 3 unit GS_KeyI;ππ{ Written by Richard F Griffinππ 1 December 1988, (Released to the public domain)ππ 1110 Magnolia Circleπ Papillion, Nebraska 68128ππ CIS 75206.231ππ This unit allows you to set data entry routines quickly and simply.π It also gives the programmer the capability to override the entryπ routine and use another procedure to handle function keys.ππ}πππinterfaceππuses crt, dos;ππtypeπ GS_KeyI_str80 = string[80];ππvarπ GS_KeyI_Chr : char;π GS_KeyI_Fuc,π GS_KeyI_Esc : boolean;π GS_KeyI_Hlp : pointer;π GS_KeyI_Psn : integer;ππFunction GS_KeyI_Get : char;ππprocedure GS_KeyI_Key(wait : boolean;Fldcnt,x,y : integer);ππfunction GS_KeyI_T(waitcr: boolean;Fl,X,Y,B:integer;CTitl,π CVal:GS_KeyI_str80) : GS_KeyI_str80;ππfunction GS_KeyI_I(waitcr:boolean;Fl,x,y,B:integer;π CTitl:GS_KeyI_str80;XVal,l,h:integer) : integer;ππfunction GS_KeyI_R(waitcr:boolean;Fl,x,y,B:integer;CTitl:GS_KeyI_str80;π XVal,l,h:real;d:integer) : real;ππimplementationππvarπ Big_String : GS_KeyI_str80;ππ{$F+}πprocedure GS_KeyI_Dum;πbeginπ write(#7);πend;π{$F-}ππ{π This procedure is an Inline far call. The address is inserted byπ GS_KeyI_Call based on the address in GS_KeyI_Hlp. This address isπ initially to GS_KeyI_Dum, but may be changed by the using program.ππ ex: GS_KeyI_Hlp := @MyProcedureππ The procedure will be called when a special function key (F1, F2,π Home, RtArrow, etc.) is pressed during data entry. The using procedureπ may then use GS_KeyI_Chr to find which key was pressed. It is up to theπ using program to ensure the screen and window sizes are properly restored.π The programmer must ensure that the $F+ option is used in the procedureπ to force a Far Return.ππ ----------- DO NOT MODIFY THIS ROUTINE ------------π}ππprocedure GS_KeyI_Jmp;πbeginπ InLine ($9A/$00/$00/$00/$00); {CALLF [GS_KeyI_Hlp]}πend;ππ{π Inserts a Far Call address for GS_KeyI_Jmp.π Works in TP 4 and 5.π}ππprocedure GS_KeyI_Call;πbeginπ MemW[seg(GS_KeyI_Jmp):ofs(GS_KeyI_Jmp)+11] := ofs(GS_KeyI_Hlp^);π MemW[seg(GS_KeyI_Jmp):ofs(GS_KeyI_Jmp)+13] := seg(GS_KeyI_Hlp^);π GS_KeyI_Jmp;πend;ππFunction GS_KeyI_Get : char;πvar ch: char;πbeginπ Ch := ReadKey;π If (Ch = #0) then { it must be a function key }π beginπ Ch := ReadKey;π GS_KeyI_Fuc := true;π endπ else GS_KeyI_Fuc := false;π GS_KeyI_Get := Ch;πend;ππprocedure GS_KeyI_Key(wait : boolean;Fldcnt,x,y : integer);πVarπ Big_S : GS_KeyI_str80;π i : integer;πbeginπ Big_s := '';π GS_KeyI_Psn := 0;π gotoxy(x,y);π Repeatπ GS_KeyI_Chr := GS_KeyI_Get;π GS_KeyI_Esc := false;π if not GS_KeyI_Fuc thenπ beginπ case GS_KeyI_Chr ofπ #08 : beginπ If GS_KeyI_Psn > 0 thenπ beginπ GS_KeyI_Psn := GS_KeyI_Psn - 1;π gotoxy(x+GS_KeyI_Psn,y);π write('_');π gotoxy(x+GS_KeyI_Psn,y);π delete(Big_S,length(Big_S),1);π end elseπ beginπ write('_');π gotoxy(x+GS_KeyI_Psn,y);π end;π end;π ' '..'}' : beginπ if (GS_KeyI_Psn = Fldcnt) and (wait) thenπ write(#7)π else beginπ if GS_KeyI_Psn = 0 thenπ beginπ for i := 1 to Fldcnt do write('_');π gotoxy(x,y);π end;π GS_KeyI_Psn := GS_KeyI_Psn + 1;π write(GS_KeyI_Chr);π Big_S := Big_S + GS_KeyI_Chr;π end;π end;π #27 : beginπ Big_S := ' ';π GS_KeyI_Esc := true;π end;π end;π end elseπ beginπ GS_KeyI_Call;π gotoxy(x+GS_KeyI_Psn,y);π end;π until (GS_KeyI_Chr in [#13,#27]) or ((GS_KeyI_Psn = Fldcnt) and (not wait));π Big_String := Big_S;πend;ππ{ The GS_KeyI_T function will process an input from the keyboard and displayπ it on the screen in a specified location. The length of the input field isπ given, as well as a default entry. The default entry is optionally shownπ on the screen.ππ Parameter descriptions are:ππ 1 Boolean flag to determine whether to wait for a carriage returnπ once the field is full.ππ 2 Length of input field.ππ 3 Horizontal location to start.ππ 4 Vertical position to start.ππ 5 Vertical line to place default value. Should be 0 to inhibitπ display of default. Will usually be the same as (4).ππ 6 The prompt to place on the screen prior to the data entry field.π Should be '' if no prompt.ππ 7 Default value.ππ}πππfunction GS_KeyI_T(waitcr: boolean;Fl,X,Y,B:integer;CTitl,π CVal:GS_KeyI_str80) : GS_KeyI_str80;πvarπ i : integer;πbeginπ GS_KeyI_T := '';π gotoxy(x,y);π write(CTitl);π for i := 1 to Fl do write('_');π if B <> 0 thenπ beginπ gotoxy(x+length(CTitl),B);π write(CVal);π end;π GS_KeyI_Key(waitcr,FL,x+length(CTitl),y);π if Big_String = '' then Big_String := CVal;π if GS_KeyI_Esc then Big_String := ' ';π gotoxy(x+length(CTitl),y);π write(Big_String,'':Fl-length(Big_String));π if (B <> 0) and (B <> Y) thenπ beginπ gotoxy(x+length(CTitl),B);π write('':length(CVal));π end;π GS_KeyI_T := Big_String;πend;ππ{ The GS_KeyI_I function will accept an integer from the keyboard and displayπ it on the screen in a specified location. The length of the input field isπ given, as well as a default entry. The default entry is optionally shownπ on the screen. A range of acceptable values is also specified.ππ Parameter descriptions are:ππ 1 Boolean flag to determine whether to wait for a carriage returnπ once the field is full.ππ 2 Length of input field.ππ 3 Horizontal location to start.ππ 4 Vertical position to start.ππ 5 Vertical line to place default value. Should be 0 to inhibitπ display of default. Will usually be the same as (4).ππ 6 The prompt to place on the screen prior to the data entry field.π Should be '' if no prompt.ππ 7 Default value.ππ 8 Lowest value acceptable.ππ 9 Highest value acceptable.ππ}πππfunction GS_KeyI_I(waitcr:boolean;Fl,x,y,B:integer;π CTitl:GS_KeyI_str80;XVal,l,h:integer) : integer;πVarπ Cod, q, i : integer;π CVal : GS_KeyI_str80;ππbeginπ str(XVal:Fl,CVal);π Cod := 1;π while Cod <> 0 doπ beginπ Big_String := GS_KeyI_T(waitcr,Fl,X,Y,B,CTitl,CVal);π if GS_KeyI_Esc thenπ beginπ GS_KeyI_I := XVal;π Exit;π end;π if Big_String[length(Big_String)] = ' ' thenπ Big_String := 'z';π for i := 1 to length(Big_String) doπ if Big_String[i] = ' ' then Big_String[i] := '0';π val(Big_String,q,Cod);π if Cod <> 0 thenπ beginπ write(chr(7));π end elseπ beginπ if (q < l) or (q > h) thenπ beginπ Cod := 1;π write(chr(7));π end;π end;π end;π GS_KeyI_I := q;πend;πππ{ The GS_KeyI_R function will accept a real number from the keyboard andπ display it on the screen in a specified location. The length of theπ input field is given, as well as a default entry. The default entryπ is optionally shown on the screen. A range of acceptable values isπ also specified.ππ Parameter descriptions are:ππ 1 Boolean flag to determine whether to wait for a carriage returnπ once the field is full.ππ 2 Length of input field.ππ 3 Horizontal location to start.ππ 4 Vertical position to start.ππ 5 Vertical line to place default value. Should be 0 to inhibitπ display of default. Will usually be the same as (4).ππ 6 The prompt to place on the screen prior to the data entry field.π Should be '' if no prompt.ππ 7 Default value.ππ 8 Lowest value acceptable.ππ 9 Highest value acceptable.ππ 10 Number of decimal places.ππ}πππfunction GS_KeyI_R(waitcr:boolean;Fl,x,y,B:integer;CTitl:GS_KeyI_str80;π XVal,l,h:real;d:integer) : real;πVarπ Cod, i : integer;π CVal : GS_KeyI_str80;π r : real;ππbeginπ str(XVal:Fl:d,CVal);π Cod := 1;π while Cod <> 0 doπ beginπ Big_String := GS_KeyI_T(waitcr,Fl,X,Y,B,CTitl,CVal);π if GS_KeyI_Esc thenπ beginπ GS_KeyI_R := XVal;π Exit;π end;π if Big_String[length(Big_String)] = ' ' thenπ Big_String := 'z';π for i := 1 to length(Big_String) doπ if Big_String[i] = ' ' then Big_String[i] := '0';π val(Big_String,r,Cod);π if Cod <> 0 thenπ beginπ write(chr(7));π end elseπ beginπ if (r < l) or (r > h) thenπ beginπ Cod := 1;π write(chr(7));π end;π end;π end;π gotoxy(x+length(CTitl),y);π str(r:Fl:d,Big_String);π write(Big_String,'':Fl-length(Big_String));π GS_KeyI_R := r;πend;ππbeginπ GS_KeyI_Hlp := @GS_KeyI_Dum;πend.ππ{---------------- DEMO PROGRAM ------------------------ }ππprogram KeyIDemo;ππuses crt, dos, GS_KeyI;ππvarπ lin : string[80];π numi : integer;π numr : real;ππ{$F+}πprocedure tst;πbeginπ window(1,20,80,24);π ClrScr;π gotoxy(20,1);π case GS_KeyI_Chr ofπ #59 : write('Function Key F1 Pressed');π #60 : write('Function Key F2 Pressed');π #61 : write('Function Key F3 Pressed');π #62 : write('Function Key F4 Pressed');π #71 : write('The Home Key was Pressed');π #79 : write('The End Key was Pressed');π elseπ write(#7);π end;π window(1,1,80,25);πend;π{$F-}ππbeginπ clrscr;π GS_KeyI_Hlp := @tst;π lin := GS_KeyI_T(true, 8,10,1,1,'Enter Text Field: ','empty');π numi := GS_KeyI_I(true, 2,10,2,2,'Enter Integer Field (0-50): ',0,0,50);π numr:= GS_KeyI_R(true, 6,10,3,3,'Enter Real Field (0-99.99): ',0,0,99.99,2);πend. 4 05-26-9411:03ALL ROBERT MASHLAN Small Input Routines SWAG9405 79 3 Unit InputUn;ππ{ This is a small unit with crash proof user input routines and someπ string formating functions. Compile the DemoInput program for moreπ information on how to use these functions.ππ Robert Mashlan [71160,3067] 3/11/89 }ππInterfaceππUses Crt;ππconstπ DefaultSet = [' '..'}'];ππVarπ InverseOn : boolean;π UpcaseOn : boolean;π ValidCharSet : set of char;ππProcedure Inverse;πProcedure UnderLine;πProcedure Normal;πProcedure Goback;πFunction ReadString( Prompt : string; Width : byte; var Escape : boolean ) : string;πFunction ReadNum( Prompt : real; Width : byte; var Escape : boolean ) : real;πFunction ReadInt( Prompt : longint; Width : byte; var Escape : boolean ) : longint;πFunction Left( AnyString : string; Width : byte ) : string;πFunction Center( AnyString : string; Width : byte ) : string;ππImplementationππconstπ esc = #27;ππProcedure Inverse;πbeginπ textbackground(white);π textcolor(black);πend;ππProcedure UnderLine;πbeginπ textbackground(white);π textcolor(blue);πend;ππProcedure Normal;πbeginπ textbackground(black);π textcolor(white);πend;πππProcedure Goback;πbeginπ GotoXY(WhereX,WhereY-1);π ClrEol;πend;ππFunction Left( AnyString : string; Width : byte ) : string;πvarπ len : byte absolute AnyString;π loop : byte;πbeginπ while length( AnyString ) < Width doπ AnyString:=AnyString+' ';π len:=Width; { truncate AnyString if Needed }π Left:=AnyString;πend;ππFunction Center( AnyString : string; Width : byte ) : string;πbeginπ repeatπ if length( AnyString ) < Widthπ then AnyString:=AnyString+' ';π if length( AnyString ) < Widthπ then AnyString:=' '+AnyString;π until length( AnyString ) >= Width;π Center:=AnyString;πend;πππFunction ReadString( Prompt : string; Width : byte; var Escape : boolean ) : string;πvarπ NewString : string;π InKey,InKey2 : char;π Start : byte;π index : integer;π InsertMode : boolean;ππ Procedure Display;π beginπ GotoXY(Start,WhereY);π if InverseOnπ then Inverse;π write(left(NewString,Width));π if InverseOnπ then Normal;π GotoXY(Start+index,WhereY);π end;ππ Procedure StripSpaces( var AnyString : string );π { decrease length of AnyString until a character until a char other than a space is found }π beginπ while AnyString[ ord(AnyString[0]) ]=' ' doπ dec(AnyString[0]);π end; { Procedure }ππππbeginπ InsertMode:=false;π Start:=WhereX;π index:=0;π NewString:=Prompt;π Display;π index:=1;π if UpCaseOnπ then Inkey:=UpCase(ReadKey)π else InKey:=ReadKey;π if InKey=#0π then beginπ InKey2:=ReadKey;π if InKey2 in [#77,#82]π then NewString:=Promptπ else NewString:='';π if Inkey2=#82π then beginπ InsertMode:=true;π index:=0;π end;π end { then }π else if InKey in ValidCharSetπ then NewString:=InKeyπ else beginπ NewString:='';π index:=0;π end;π if InKey=escπ then beginπ ReadString:=Prompt;π Escape:=true;π ValidCharSet:=defaultSet;π exit;π end;π if InKey=#13π then beginπ Escape:=false;π ReadString:=Prompt;π ValidCharSet:=DefaultSet;π exit;π end;π Display;π repeatπ if UpCaseOnπ then Inkey:=Upcase(readkey)π else InKey:=ReadKey;π if (InKey in ValidCharSet)π then beginπ if not InsertModeπ then Delete(NewString,index+1,1);π insert(InKey,NewString,index+1);π if index<> Width then inc(index)π end;π if (length(NewString)<>0) and (InKey=#8) { backspace }π then beginπ Delete(NewString,index,1);π if index<>0π then dec(index);π end;π if InKey=#0π then beginπ InKey:=ReadKey;π case InKey ofπ #77 : if (index<>length(NewString)) and (' ' in ValidCharSet)π then inc(index)π else if (index+1<>Width) and (' ' in ValidCharSet)π then beginπ NewString:=NewString+' ';π inc(index);π end;π #75 : if index<>0π then if length(NewString)+1<>indexπ then dec(index)π else if NewString[index]=' 'π then beginπ NewString[0]:=succ(NewString[0]);π dec(index);π endπ else dec(index);π #83 : if length(NewString)>0 then Delete(NewString,index+1,1);π #82 : if InsertModeπ then InsertMode:=falseπ else InsertMode:=true;π end; { case }π end; { then }π if Length(NewString)>width then dec( NewString[0] );π if index >= width then dec(index);π Display;π until (InKey=#13) or (InKey=esc);π ValidCharSet:=DefaultSet;π if not ( (InKey=esc) or (length(NewString)=0))π then beginπ StripSpaces(NewString);π ReadString:=NewStringπ endπ else ReadString:=Prompt;π if InKey=escπ then Escape:=trueπ else Escape:=false;ππend; { Procedure }ππFunction ReadNum( Prompt : real; Width : byte; var Escape : boolean ) : real;πvarπ NewString : string;π code : integer;π OldNum : real;π Start : byte;πbeginπ OldNum:=Prompt;π Start:=WhereX;π repeatπ GotoXY(Start,WhereY);π str( Prompt:0:2, NewString );π ValidCharSet:=['0'..'9','.','-',' '];π NewString:=ReadString( NewString, Width, Escape );π val(NewString,Prompt,code);π until Escape or (code=0);π if Escape or (code<>0)π then ReadNum:=OldNumπ else ReadNum:=Prompt;πend;ππFunction ReadInt( Prompt : longint; Width : byte; var Escape : boolean ) : longint;πvarπ NewString : string;π code : integer;π OldNum : longint;π Start : byte;πbeginπ OldNum:=Prompt;π Start:=WhereX;π repeatπ GotoXY(Start,WhereY);π str( Prompt, NewString );π ValidCharSet:=['0'..'9','-',' '];π NewString:=ReadString( NewString, Width, Escape );π val(NewString,Prompt,code);π until Escape or (code=0);π if Escapeπ then ReadInt:=OldNumπ else ReadInt:=Prompt;πend;ππbeginπ InverseOn:=true;π UpcaseOn:=false;π ValidCharSet:=DefaultSet;πend.ππ{ ----------------------------- DEMO PROGRAM ----------------------- }πProgram DemoInputUnit;ππUsesπ Crt, InputUn;ππvarπ InKey : char;π AnyString : string;π AnyInt : longint;π AnyNum : real;π Escape : boolean;ππbeginπ ClrScr;π writeln;π Inverse;π writeln(' Text in Inverse mode ');π writeln;π Underline;π writeln(' Text in Underline mode ( if using a monochrome monitor)');π writeln;π normal;π writeln(' Back to normal ');π writeln;π writeln(' The GoBack procedure is used...(press any key)................ ');π Inkey:=readkey;π goback;π writeln(' To erase a line and write a new one (press any key) ');π InKey:=readkey;π ClrScr;π writeln(' The ReadString function takes 3 parameters');π writeln(' Function ReadString( Prompt : string; width : byte; var Escape : boolean )');π writeln(' : string;');π writeln(' Prompt is the string that is first put into the edit field.');π writeln(' This is the string that the function returns if the function is exited with');π writeln(' an Esc at any time, or a return while it is there.');π writeln(' This prompt may be edited if the right arrow or the insert key is pressed');π writeln(' on the first input, otherwise the prompt will disappear. The return key ');π writeln(' will input all the visible characters in the field and exit the function.');π writeln(' The Del, left and right arrow keys work as does the backspace.');π writeln(' The Ins key toggles the insert mode where new characters are inserted ');π writeln(' instead of written over. It is initially off.');π writeln(' Esc will also exit the function, return the prompt as the result and set ');π writeln(' the Escape parameter to true (otherwise set to false with a return');π writeln(' the width parameter sets the maximum length of the string');π writeln(' This field is highlighted in Inverse. It may be turned off by setting the');π writeln(' InverseOn to true. Another Global varible that affects this function is');π writeln(' ValidCharSet which is initially set to the set of all printable characters.');π writeln(' You can change it before calling this function, and is reset to the ');π writeln(' DefaultSet const after calling it. The InverseOn varible will convert');π writeln(' all letters to uppercase if set to true. It is initially set to false');π writeln;π repeatπ write('Input a string->');π AnyString:=ReadString('This is your prompt',20,escape);π writeln;π goback;π if escapeπ then write(' Escape Exit ');π writeln('Your string is ''',AnyString,'''');π inkey:=readkey;π goback;π write('Input an integer ( ReadInt )->');π AnyInt:=ReadInt(123,5,Escape);π writeln;π goback;π if escapeπ then write(' Escape Exit ');π writeln('Your integer is ',AnyInt);π if escape then exit;π inkey:=readkey;π goback;π write('Input a real number ( ReadNum )->');π AnyNum:=ReadNum(1.23,8,escape);π writeln;π goback;π if escapeπ then write(' Escape Exit ');π writeln('Your Number is ',AnyNum:0:5);π if escape then exit;π if not escapeπ then beginπ Inkey:=readkey;π goback;π end;π until escape;πend.ππππππ